Documentation Center

Using Web Service in C# [deprecated]

This is a short example for a C# .NET web service call.

Before you begin

This working example was created on June 2011 using the following prerequisites:
  • Availability of the Microsoft .NET FrameWork
  • Microsoft Visual Studio

About this task

Presuming you have the prerequisites installed:
  1. Create a Visual Studio Project, e.g. a Console Application
  2. Add a web service reference
    1. Navigate to the project and right click References section. Select Add Service Reference...
    2. To add an ASMX based web service reference, click the Advanced... button below
    3. Now click Add Web Reference..., now add as URL: http://ish.example.com/ISHWS/Application25.asmx (where ish refers to an example server dedicated to Content Manager) and name it InfoShareApplication25
  3. Inside the code you should now be able to write something like:
    using System;
    
    namespace ExampleConsoleApplication
    {
        class Program
        {
            // Used to prefix every web service call, easy redirect to different web/app server
            static string baseUrl = "http://ish.example.com/ISHWS/";
    
            static void Main(string[] args)
            {
                try
                {
                    string myContext = GetContext();
                    Console.WriteLine("myContext[" + myContext + "]");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                    Console.WriteLine(exception.StackTrace);
                }
                Console.ReadLine();
            }
    
            static string GetContext()
            {
                //Creating the objects
                InfoShareApplication25.Application25 myInfoShareApplication25 = new InfoShareApplication25.Application25();
                string myContext = "";
                //Redirecting the dynamic URL to the current test machine
                myInfoShareApplication25.Url = baseUrl + "Application25.asmx";
                //Doing the login call
                myInfoShareApplication25.Login("ISHCM", "Admin", "admin", ref myContext);
                return myContext;
            } 
        }
    }
  4. Execution should give you an encrypted context in variable myContext.